let iframeElement = document.createElement('iframe');
iframeElement.setAttribute('id', 're_html');
// iframeElement.onload = onLoadCallback
document.body.appendChild(iframeElement);

let that = this
window.addEventListener("message", function(event) {
    if (event.source != window)
        return;
    if (event.data.from && (event.data.from == "FROM_CONTENT_SCRIPT")) {
        console.log('收到Content消息：' + JSON.stringify(event.data));
        if (event.data.name === MsgDef.MSG_REQ_DATA) {
            iframeElement.srcdoc = event.data.data.html;
            iframeElement.style.opacity = event.data.data.alpha;
            iframeElement.style.left = event.data.data.x + 'px';
            iframeElement.style.top = event.data.data.y + 'px';
            iframeElement.style.transform = 'scale(' + event.data.data.scale + ')';
        }
    }
})

function sendMsgToContent(name, data) {
    console.log('sendMsgToContent')
    window.postMessage({
        name: name,
        data: data ? data : {},
        from: 'FROM_PAGE'
    }, "*");
}

// setInterval(()=> {
sendMsgToContent(MsgDef.MSG_REQ_DATA);
// }, 1000)